<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>htmlcss 阶段</title>
    <style></style>
</head>
<body>



<script>
    // 写一个函数，能获取文件后缀
    function getSuffix(url) {
        var res = url.slice(-4);
        console.log(res);
    }
    // 例如：
    getSuffix("./images/demo.txt");// .txt
    getSuffix("./images/example.jpg");// .jpg



</script>
</body>
</html>